<html> 
<head> 

<title>Basic XY Positioning</title> 
 
<style type="text/css"> 
/*margin and padding on body element
  can introduce errors in determining
  element position and are not recommended;
  we turn them off as a foundation for YUI
  CSS treatments. */
body {
    margin:0;
    padding:0;
}
</style> 

<link type="text/css" rel="stylesheet" href="https://yuicombo.appspot.com/combo?3.0.0/build/cssfonts/fonts-min.css" /> 
<script type="text/javascript" src="https://yuicombo.appspot.com/combo?3.0.0/build/yui/yui-min.js"></script> 

 

 
<!--begin custom header content for this example--> 
<style type="text/css"> 
/* Overlay Look/Feel */
.yui-overlay-content {
    padding:3px;
    border:1px solid #000;
    background-color:#aaa;
}
 
.yui-overlay-content .yui-widget-hd {
    padding:5px;
    border:2px solid #aa0000;
    background-color:#fff;
}
 
.yui-overlay-content .yui-widget-bd {
    padding:5px;
    border:2px solid #0000aa;
    background-color:#fff;
}
 
.yui-overlay-content .yui-widget-ft {
    padding:5px;
    border:2px solid #00aa00;
    background-color:#fff;
}
 
/* Example Layout CSS */
.overlay-example {
    border:1px solid #000;
    background-color:#eee;
    padding:5px;
    margin:10px 0;
    height:15em;
}
 
.overlay-example button, .overlay-example label, .overlay-example select, .overlay-example input {
    margin-right:1px;
}
 
.overlay-example select.needs-shim {
    width:100%;
}
 
.overlay-example .filler {
    color:#999;
}
 
#show {
    margin-left:15px;
}
 
#x, #y {
    width:3em;
}
</style> 
 
<!--end custom header content for this example--> 
 
</head> 
 
<body class=" yui-skin-sam"> 
 
<h1>Basic XY Positioning</h1> 
 
<div class="exampleIntro"> 
    <p>This example walks you through basics of creating and positioning an Overlay. It walks you through setting up the sandbox environment for the Overlay, including the required modules, and instantiating the Overlay based on markup already on the page.</p> 
<p>It also provides a couple of input fields, allowing you to invoke the Overlay's <code>move()</code> method, to move the Overlay to a specific XY position on the page.</p> 
 
            
</div> 
 
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> 
 
<div class="overlay-example" id="overlay-position"> 
 
    <label>X: <input type="text" id="x" value="0" /></label> 
    <label>Y: <input type="text" id="y" value="0" /></label> 
    <button type="button" id="move">Move</button> 
    <button type="button" id="show">Show</button> 
    <button type="button" id="hide">Hide</button> 
 
    <div id="overlay"> 
        <div class="yui-widget-hd">Overlay Header</div> 
        <div class="yui-widget-bd">Overlay Body</div> 
        <div class="yui-widget-ft">Overlay Footer</div> 
    </div> 
 
    <p class="filler"> 
        <select class="needs-shim"> 
            <option>Prevent IE6 Bleedthrough</option> 
        </select> 
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc pretium quam eu mi varius pulvinar. Duis orci arcu, ullamcorper sit amet, luctus ut, interdum ac, quam. Pellentesque euismod. Nam tincidunt, purus in ultrices congue, urna neque posuere arcu, aliquam tristique purus sapien id nulla. Etiam rhoncus nulla at leo. Cras scelerisque nisl in nibh. Sed eget odio. Morbi elit elit, porta a, convallis sit amet, rhoncus non, felis. Mauris nulla pede, pretium eleifend, porttitor at, rutrum id, orci. Quisque non urna. Nulla aliquam rhoncus est. 
    </p> 
</div> 
 
<script type="text/javascript"> 
YUI({combine: true, timeout: 10000, comboBase : 'https://yuicombo.appspot.com/combo?'}).use("overlay", function(Y) {
 
    var xy = Y.one("#overlay-position").getXY();
 
    // Create an overlay from markup
    var overlay = new Y.Overlay({
        contentBox:"#overlay",
        width:"10em",
        height:"10em",
        xy:[xy[0] + 10, xy[1] + 35]
    });
    overlay.render();
 
    var xInput = Y.one("#x");
    var yInput = Y.one("#y");
 
    // Using round to round sub-pixel values for FF3 just 
    // to make the text box values prettier.
    xInput.set("value", Math.round(overlay.get("x")));
    yInput.set("value", Math.round(overlay.get("y")));
 
    Y.on("click", function(e) {
        var x = parseInt(xInput.get("value"));
        var y = parseInt(yInput.get("value"));
        overlay.move(x,y);
    }, "#move");
 
    Y.on("click", Y.bind(overlay.show, overlay), "#show");
    Y.on("click", Y.bind(overlay.hide, overlay), "#hide");
});
</script> 
 
<!--END SOURCE CODE FOR EXAMPLE =============================== --> 
 
</body> 
</html> 
